<template>
	<div class="hecheng_box">
		<div style="margin-left: 20px;">视频合成</div>
		<div class="kuang">

			<div class="caoz">
				<div>
					<el-form label-position="right" label-width="120px" :model="form">
						<SyntheticOne :formData.sync="form" v-if="status == 0"></SyntheticOne>

						<el-form-item style="position: relative;" v-if="status == 0">
							<el-button size="mini" type="primary" @click="submit()">创建合成任务</el-button>
						</el-form-item>

						<el-form-item style="position: relative;" label-width="0" v-if="status == 1">
							<div>
								<el-button size="mini" type="primary" @click="last">《上一步</el-button>

								<el-button size="mini" type="primary" @click="add_mu">新增幕</el-button>

								<el-button size="mini" :type="type_ys" plain  @click="to_last">下一步》</el-button>
							</div>
						</el-form-item>
						<el-form-item style="position: relative;" label-width="0" v-if="status == 2">
							<div>
								<el-button size="mini" type="primary" @click="lasttwo">《上一步</el-button>
								<el-button size="mini" type="primary" @click="submit">合成</el-button>
							</div>
						</el-form-item>
					</el-form>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
    import qs from 'qs'
    import {
        getVideoCreate,
    } from "../../../api";
	import SyntheticOne from './components/SyntheticOne.vue';
	import SyntheticThree from './components/SyntheticThree.vue';
	export default {
		//存放 数据
		data: function() {
			return {
        form: {
          number: 1,
          yinliang: 30,
          cichun: '最大',
          editor_name:"",
          material_a_file_id: [],
          material_a_file_name:'',
          material_b_file_id: [],
          material_b_file_name:'',
          data: [
            {
              id: 0,
              cover: [],
              videoList: []
            }
          ],
          donghua_list: [],
          material_c_file_id:[],
          material_c_file_name:'',
          material_d_file_id:[],
          material_d_file_name:'',
          material_e_file_id:[],
          material_e_file_name:'',
          material_f_file_id:[],
          material_f_file_name:'',
          material_g_file_id:[],
          material_g_file_name:'',
          material_bgm_file_id:[],
          material_bgm_file_name:'',
        },
				next: true,
				status: 0,
				type_ys: 'info'

			}
		},
		/*  生命周期函数  */
		//创建期间
		beforeCreate() {},
		created() {},
		beforeMount() {},
		mounted() {

		},
		//运行期间
		beforeUpdate() {},
		updated() {},
		//销毁时期
		beforeDestroy() {},
		destroyed() {},
		//存放 方法
		methods: {
			xiayibu() {
				this.status = 1
			},
			last() {
				this.status = 0
			},
			to_last(){
				this.status = 2
			},
			lasttwo(){
				this.status = 1
			},
			add_zhuanchang(){
				console.log("==========")
				console.log('ssss')
				let _data = this.common.deepClone(this.form)
				_data.donghua_list.push({
					value: '',
				})
				this.form = _data
				console.log(_data.donghua_list)

			},
			add_mu(){
				console.log("==========")
				console.log('ssss')
				let _data = this.common.deepClone(this.form)
				_data.data.push({
					id: 0,
					cover: [],
					videoList: []
				})
				this.form = _data
				console.log(_data.data)
			},
            async submit() {
                console.log("this.form.material_a_file_id");
                console.log(this.form.material_a_file_id);
                console.log(this.form.material_b_file_id);
                console.log(this.form.material_c_file_id);
                console.log(this.form.material_d_file_id);
                console.log(this.form.material_e_file_id);
                console.log(this.form.material_f_file_id);
                console.log(this.form.material_g_file_id);
                console.log(this.form.material_bgm_file_id);
				let params={
                    number:Number(this.form.number),
                    sound:Number(this.form.yinliang),
                    editor_name:this.form.editor_name
				};
                if(this.form.material_a_file_id.length!=0){
                    params.material_a_file_id=this.form.material_a_file_id[0]
                }
                if(this.form.material_b_file_id.length!=0){
                    params.material_b_file_id=this.form.material_b_file_id[0]
                }
                if(this.form.material_c_file_id.length!=0){
                    params.material_c_file_id=this.form.material_c_file_id[0]
                }
                if(this.form.material_d_file_id.length!=0){
                    params.material_d_file_id=this.form.material_d_file_id[0]
                }
                if(this.form.material_e_file_id.length!=0){
                    params.material_e_file_id=this.form.material_e_file_id[0]
                }
                if(this.form.material_f_file_id.length!=0){
                    params.material_f_file_id=this.form.material_f_file_id[0]
                }
                if(this.form.material_g_file_id.length!=0){
                    params.material_g_file_id=this.form.material_g_file_id[0]
                }
                if(this.form.material_bgm_file_id.length!=0){
                    params.material_bgm_file_id=this.form.material_bgm_file_id[0]
                }
                console.log(params);
                let res = await getVideoCreate(params).catch((e) => e);
                if (res.code == 200 || res.msg == "success") {
                    this.$message({
                        showClose: true,
                        message: '正在合成中...',
                        type: 'success',
                    });

                    this.$emit("update:tabindex", 3)
                }
				/*this.http.post(this.api.apiUrlShipin+`/admin/hecheng/submit`, {
					'form[cichun]': this.form.cichun,
					'form[number]': this.form.number,
					'form[yinliang]': this.form.yinliang,
					'form[bgm]': this.form.bgm,
					'form[zimu]': this.form.zimu,
					'form[wuliao_list]': wuliao_list,
				})
				.then(res => {
					if (res) {
						console.log("resdata", res.data)
						this.$message({
							showClose: true,
							message: '正在合成中...',
							type: 'success',
						});

						this.$emit("update:tabindex", 3)

					}
				})
*/

			}
		},
		components: {
			SyntheticOne,
			SyntheticThree
		},
		//存放 过滤器
		filters: {},
		//自定义 私有指令
		directives: {},
		// 注意： 组件中的 所有 props 中的数据，都是通过 父组件传递给子组件的
		// props 中的数据，都是只读的，无法重新赋值
		// props: [], // 把父组件传递过来的 parentmsg 属性，先在 props 数组中，定义一下，这样，才能使用这个数据
	}
</script>

<style scoped>
	.kuang {
		display: flex;
	}

	.caoz {
		height: 100%;
		min-height: 400px;
		flex: 1 1;
		padding: 0 20px;
		/*border-left: 1px dashed #777;*/
	}
</style>
